package top.cyixlq.chat.utils

import org.json.JSONObject
import top.cyixlq.chat.entity.MessageBean

fun MessageBean.toJson(): String = "{content: \"${content}\", nickName: \"${nickName}\"}"

fun String.toMessageBean(): MessageBean {
    val jsonObject = JSONObject(this)
    return MessageBean(
            true,
            jsonObject.getString("content"),
            jsonObject.getString("nickName")
    )
}